package abstract_factory

type Pay interface {
	Pay() string
}

type Refund interface {
	Refund() string
}

type PayFactory interface {
	CreatePay() Pay
	CreateRefund() Refund
}

type AliPay struct {
}

func (AliPay) Pay() string {
	return "支付宝支付"
}

type AliPayRefund struct{}

func (AliPayRefund) Refund() string {
	return "支付宝退款"
}

type WechatPay struct {
}

func (WechatPay) Pay() string {
	return "微信支付"
}

type WechatPayRefund struct{}

func (WechatPayRefund) Refund() string {
	return "微信退款"
}

type AliPayFactory struct{}

func (AliPayFactory) CreatePay() Pay {
	return AliPay{}
}

func (AliPayFactory) CreateRefund() Refund {
	return AliPayRefund{}
}

type WechatPayFactory struct{}

func (WechatPayFactory) CreatePay() Pay {
	return WechatPay{}
}

func (WechatPayFactory) CreateRefund() Refund {
	return WechatPayRefund{}
}

func NewPayFactory(typ int) PayFactory {
	switch typ {
	case 1:
		return AliPayFactory{}
	case 2:
		return WechatPayFactory{}
	default:
		return AliPayFactory{}
	}
}
